import { useViewer } from '@/stores/viewer';
const viewer: any = useViewer().viewer;
let stopTime: null = null;

// 日照分析
function startRZFX(startDate: any, endDate: any) {
  viewer.clock.shouldAnimate = true;
  if (stopTime) {
    viewer.clock.currentTime = stopTime;
  } else {
    viewer.scene.globe.enableLighting = true;
    viewer.shadows = true;
    viewer.clock.startTime = Cesium.JulianDate.fromDate(startDate);
    viewer.clock.currentTime = Cesium.JulianDate.fromDate(startDate);
    viewer.clock.stopTime = Cesium.JulianDate.fromDate(endDate);
    viewer.clock.clockRange = Cesium.ClockRange.LOOP_STOP;
    viewer.clock.clockStep = Cesium.ClockStep.SYSTEM_CLOCK_MULTIPLIER;
    viewer.clock.multiplier = 1600;
  }
}

function stopRZFX() {
  stopTime = viewer.clock.currentTime;
  viewer.clock.shouldAnimate = false;
}

function destroyRZFX() {
  viewer.clock.clockRange = Cesium.ClockRange.UNBOUNDED;
  viewer.clock.multiplier = 1;
  viewer.shadows = false;
}
//

export { startRZFX, stopRZFX, destroyRZFX };
